package com.whty.cms.filewps.common.service;

import com.whty.cms.filewps.util.Pagination;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;

import java.util.List;

public interface MongoService {
	
	<T> void insert(T entity) throws Exception;
	
	<T> void insert(T entity, String collectionName) throws Exception;
	
	<T> T findOne(Query query, Class<T> clazz) throws Exception;
	
	<T> T findOne(Query query, Class<T> clazz, String collectionName) throws Exception;
	
	<E> List<E> list(Query query, Class<E> clazz) throws Exception;
	
	<E> List<E> list(Query query, Class<E> clazz, String collectionName) throws Exception;
	
	<T> long count(Query query, Class<T> clazz) throws Exception;
	
	long count(Query query, String collectionName) throws Exception;
	
	<E> List<E> listForPagination(Pagination pagination, Query query, Class<E> clazz) throws Exception;
	
	<E> List<E> listForPagination(Pagination pagination, Query query, Class<E> clazz, String collectionName) throws Exception;
	
	<T> void remove(Query query, Class<T> clazz) throws Exception;
	
	<T> void remove(Query query, String collectionName) throws Exception;
	
	<T> void updateFirst(Query query, Update update, Class<T> clazz) throws Exception;
	
	void updateFirst(Query query, Update update, String collectionName) throws Exception;
	
	<T> void updateMulti(Query query, Update update, Class<T> clazz) throws Exception;
}
